package com.study.designpattern.singleton;

import org.omg.Messaging.SYNC_WITH_TRANSPORT;

public class hungrySingletonTest {
    public static void main(String[] args) {
        hungrySingleton instance=hungrySingleton.getInstance();
        hungrySingleton instance1=hungrySingleton.getInstance();
        System.out.println(instance==instance1);

    }
}
class hungrySingleton{
    //声明且初始化，饿汉，通过JVM加载机制保证单例
    private static hungrySingleton instance=new hungrySingleton();
    private hungrySingleton(){

    }

    public static hungrySingleton getInstance() {
        return instance;
    }
}